import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import todayData from './modules/todayData'
import login from './modules/login'
import channel from './modules/channel'
import teamExtend from './modules/teamExtend'
import myInformation from './modules/myInformation'
import share from './modules/share'
import test from './modules/test'
import teamClock from './modules/teamClock'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'login',
    component: () => import('../views/login/login.vue')
  },
  ...login,
  todayData,
  channel,
  ...teamExtend,
  share,
  ...myInformation,

  ...test,
  teamClock
]

const router = new VueRouter({
  routes
})

router.afterEach((to, from) => {
  if (to.meta.title) {
    window.document.title = to.meta.title
  }
  
  document.body.scrollTop = document.documentElement.scrollTop = 0

  var loading =  document.getElementById('loading1')
  if (loading) {
    loading.parentNode.removeChild(loading)
  }
})

export default router
